package main

import (
	"time"

	"github.com/kataras/iris/v12"
)

type Person struct {
	Name       string    `form:"name" json:"name" url:"name" msgpack:"name"`
	Address    string    `form:"address" json:"address" url:"address" msgpack:"address"`
	Birthday   time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1" json:"birthday" url:"birthday" msgpack:"birthday"`
	CreateTime time.Time `form:"createTime" time_format:"unixNano" json:"create_time" url:"create_time" msgpack:"createTime"`
	UnixTime   time.Time `form:"unixTime" time_format:"unix" json:"unix_time" url:"unix_time" msgpack:"unixTime"`
}

func main() {
	app := iris.Default()
	app.Any("/", index)
	app.Listen(":8080")
}

func index(ctx iris.Context) {
	var person Person
	if err := ctx.ReadBody(&person); err != nil {
		ctx.StopWithError(iris.StatusBadRequest, err)
		return
	}

	ctx.Application().Logger().Infof("Person: %#+v", person)
	ctx.WriteString("Success")
}
